package defectsim;

public class SlipSystem {

	private int planeX, planeY, planeZ;
	private int dirX, dirY, dirZ;
	
	
	public SlipSystem(int px, int py, int pz, int dx, int dy, int dz){
		planeX = px;
		planeY = py;
		planeZ = pz;
		dirX = dx;
		dirY = dy;
		dirZ = dz;
	}
	
	/**
	 * @param ax, ay, az are unit directions of applied stress 
	 * @returns Schmidt factor
	 */
	public double SchmidtFactor(int ax, int ay, int az){
		
		double cosPhi = (planeX * ax + planeY * ay + planeZ * az) / 
			Math.sqrt((planeX * planeX + planeY * planeY + planeZ * planeZ) * (ax * ax + ay * ay + az * az));
		
		double cosLambda = (dirX * ax + dirY * ay + dirZ * az) / 
			Math.sqrt((dirX * dirX + dirY * dirY + dirZ * dirZ) * (ax * ax + ay * ay + az * az));
		
		return cosPhi * cosLambda;
	}
}
